package com.vader.juc.sysc;

import java.util.TreeMap;
import java.util.concurrent.TimeUnit;

class Phone{
    public synchronized void sendSms() throws InterruptedException {
        TimeUnit.SECONDS.sleep(4);
        System.out.println("sendSms=======>sms");
    }

    public synchronized void sendEmail(){
        System.out.println("sendEmail=========>email");
    }

    public void sendHello(){
        System.out.println("sendHello=======>hello");
    }

}


/**
 * @author kaivader
 */
public class Lock_8 {
    public static void main(String[] args) {
        Phone phone = new Phone();

        new Thread(()->{
            try {
                phone.sendSms();
            }catch (Exception e){
                e.printStackTrace();
            }
        },"A").start();

        new Thread(()->{
            try {
                phone.sendEmail();
            }catch (Exception e){
                e.printStackTrace();
            }
        },"B").start();

//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                phone.sendHello();
//            }
//        },"C").start();

    }
}
